#include "histScrollArea.h"

histScrollArea::histScrollArea(QWidget *parent)
		: QScrollArea(parent)
{
}

void histScrollArea::copyHistories() const
{
	QString res;
	foreach ( historyWidget *histWgt, histories )
	{
		if ( histWgt->selected() ) {
			res += histWgt->resultText();
		}
	}
	qApp->clipboard()->setText(res);
}

void histScrollArea::clearHistory()
{
	foreach ( historyWidget *histWgt, histories )
	{
		if ( histWgt->selected() ) {
			histories.removeAll(histWgt);
			histWgt->deleteLater();
		}
	}
}

void histScrollArea::selectAllClicked() const {
	foreach ( historyWidget *histWgt, histories ) {
		histWgt->select();
	}
}

void histScrollArea::unSelectAllClicked() const {
	foreach ( historyWidget *histWgt, histories ) {
		histWgt->select(false);
	}
}

void histScrollArea::addHistWidget(historyWidget *hist) {
	this->widget()->layout()->addWidget(hist);
	histories.append(hist);
}











